<template>
  <div>
    <button @click="changeId">test</button>
    <uploader :options="options" :file-status-text="statusText" class="uploader-example" ref="uploader" @file-complete="fileComplete" @complete="complete">
      <uploader-drop style="display: flex;justify-content: center;flex-wrap: wrap;">
          <p align="center" style="width: 100%">拖曳文件到此处上传，或者</p>
          <uploader-btn>选持文件</uploader-btn>
      </uploader-drop>
      <uploader-list></uploader-list>
    </uploader>
  </div>
</template>

<script>
  export default {
    data () {
      return {
        testId: '01',
        options: {
          target: 'http://10.70.49.169:8080/bm/api/v1/doc_manage/multiple_upload_data',
          ossInitTarget: 'http://10.70.49.169:8080/bm/api/v1/doc_manage/multiple_upload_init',
          ossCompleteTarget: 'http://10.70.49.169:8080/bm/api/v1/doc_manage/oss_callback',
          chunkSize: 1024 * 1024,
          testChunks: false,
          uploadMethod: 'POST',
          ossRelateInst: 'doc_test',
		      ossRelateInstId: '01',
          simultaneousUploads: 1,
          headers: {
            'AUTH_TOKEN': '3a9db9f1-6606-411a-9279-ebe2c18e4237'
          }
        },
        attrs: {
          accept: 'image/*'
        },
        statusText: {
          success: '成功了',
          error: '出错了',
          uploading: '上传中',
          paused: '暂停中',
          waiting: '等待中'
        }
      }
    },
    methods: {
      complete () {
        console.log('complete', arguments)
      },
      fileComplete (file) {
        console.log('file complete', file)
      },
      changeId () {
        this.options.ossRelateInstId = '02';
      }
    },
    mounted () {
      this.$nextTick(() => {
        window.uploader = this.$refs.uploader.uploader
      })
    }
  }
</script>

<style>
  .uploader-example {
    width: 880px;
    padding: 15px;
    margin: 40px auto 0;
    font-size: 12px;
    box-shadow: 0 0 10px rgba(0, 0, 0, .4);
  }
  .uploader-example .uploader-btn {
    margin-right: 4px;
  }
  .uploader-example .uploader-list {
    max-height: 440px;
    overflow: auto;
    overflow-x: hidden;
    overflow-y: auto;
  }
</style>
